package com.share.alibaba.agetway.service.impl;

import com.share.alibaba.agetway.feign.AUserFeignClient;
import com.share.alibaba.agetway.model.AccessLog;
import com.share.alibaba.agetway.service.AccessService;
import com.share.common.common.Result;
import com.share.common.enums.ErrMsgEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class AccessServiceImpl implements AccessService {

    @Resource
    private AUserFeignClient aUserFeignClient;

    @Override
    public int saveAccessLog(AccessLog accessLog) {
        Result result = aUserFeignClient.saveAccessLog(accessLog);
        if (ErrMsgEnum.SUCCESS.code.equals(result.getCode())) {
            return 1;
        } else {
            log.warn("访问日志-保存失败msg={},reqdata={}", result, accessLog.toJSONString());
            return 0;
        }
    }
}
